package com.itheima.myscoket.Demo4;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/*
服务器
 */
public class Demo2 {
    public static void main(String[] args) throws IOException {
        //创建server对象
        ServerSocket ss = new ServerSocket(10000);
        //接收数据
        Socket accept = ss.accept();
        //获得输入流对象
        InputStream is = accept.getInputStream();
        //定义一个临时变量
        int len;
        //循环读取数据,打印
        while ((len = is.read()) != -1) {
            System.out.print((char) len);
        }
        //释放资源
        is.close();
        ss.close();
    }
}
